<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>菲波那切数列</title>
		<style type="text/css">
			body{
				font-size: 20px;
				text-align: center;
			}
		</style>
	</head>
	<body>
		
	</body>
</html>
<script>
	
	 function fibonacci(index) {

        var num1 = 0;
        var num2 = 1;
        var num3;

        document.write(num1 + "<br/>");
        document.write(num2 + "<br/>");

        for (var i = 3; i <= index; i++) {

            num3 = num1 + num2;
            num1 = num2;
            num2 = num3;

//          if (num3 > index) {
//              break;
//          }
            document.write(num3 + "<br/>");
        }
    }

 
  fibonacci(20);
</script>